<template>
  <div class="chart-detail">
    <div class="" style="height:70px;" v-show="canShow"></div>
    <!-- 头部显示 -->
    <div class="detail-top detail-top-layout" :class="leftAnimate" :style="{width: navWidth + 'px', top: top + 'px'}">
      <div class=" nav-top-title">
        离校未就业高校毕业生实名登记情况
      </div>
    </div>
    <!-- 详情 -->
    <div class="detail-box detail-box-layout" :style="{ top: top  - 10 +  'px'}" style="margin-top: 0"  >
      <!-- 详情头部 -->
      <div class="chart-title-layout second-search">
        <!-- 头部左侧显示 -->
        <h3 class="chart-title">
          <div class="area-title-name" @mouseenter="mouseenter()"
               @mouseleave="mouseleave()">{{ this.year }}年度
          </div>
        </h3>
        <!-- 头部右侧筛选 -->
        <div class="search-right">
          <div class="secondSearchBtn">
            <a href="#/humanResources/detail/graduates-employment-detail"
               class="chart-next next-btn">离校未就业高校毕业生就业登记台账 >>></a>
          </div>
        </div>
        <!-- 头部左侧显示浮窗  -->
        <div class="chart-title-floating" v-show="showFloating">
          <span>年份: {{ this.year }}</span>
        </div>
      </div>
      <!-- 详情内容 -->
      <div :class="this.isShowChart ? '' : 'chart-content-wrapper'"
           style="height: 100%; overflow: auto; padding-top: 64px"
           :style="{height: this.isShowChart ? '100%' : this.height - 64 + 'px'}">
        <div class="help-message" @click="showHelpMessageBox">
          <div class="help-message-wrapper">
            <span>就业服务流程</span>
            &nbsp;
            <span>
              <i class="icon-help-describe" style="font-size: 20px;"></i>
            </span>
          </div>
        </div>
        <!-- 详情 -->
        <div class="content" style="height: 100%;" v-show="isShowChart">
          <!--头部-->
          <div class="content-head" style="height: 100px; padding-top: 10px" v-show="isShowChart">
            <div class="distribution-insured-persons-wrapper">
              <ul>
                <li class="left-card">
                  <div class="content-left">
                    <img src="../../assets/img/chart-svg/not-employed.svg" alt="" class="card-icon">
                    <span class="card-title">离校未就业</span>
                  </div>
                  <div class="content-right">
                    <span class="min-card-subTitle">总人数</span>
                    <p>
                      <span class="card-number">{{ this.allTotal }}</span>
                      <span class="card-numberUnit-numberRatio">
                      人
                    </span>
                    </p>
                  </div>
                </li>
                <li class="middle-card">
                  <div class="content-left">
                    <img src="../../assets/img/chart-svg/employed.svg" alt="" class="card-icon">
                    <span class="card-title">已完成就业</span>
                  </div>
                  <div class="content-right">
                    <span class="min-card-subTitle">人数</span>
                    <p>
                      <span class="card-number">{{ this.job_total }}</span>
                      <span class="card-numberUnit-numberRatio">
                      人
                      </span>
                    </p>
                  </div>
                </li>
                <li class="right-card">
                  <div class="content-left">
                    <img src="../../assets/img/chart-svg/employed-rate.svg" alt="" class="card-icon">
                    <span class="card-title">就业率</span>
                  </div>
                  <div class="content-right">
                    <span class="min-card-subTitle">就业率</span>
                    <p>
                      <span class="card-number">{{ this.rate }}</span>
                      <span class="card-numberUnit-numberRatio">
                      %
                      </span>
                    </p>
                  </div>
                </li>
              </ul>
            </div>
          </div>
          <!-- 就业情况分析 -->
          <div class="top-two-chart" style="width: 100%; height: 340px; border-bottom: 1px solid #1d2027">
            <!-- 就业服务与就业情况分析 -->
            <div class="two-chart-left">
              <div class="chart-container" v-show="isShowChart">
                <div class="four-chart-mini-title">
                  <span>就业服务与就业情况分析</span>
                  <span class="title-bk-container"></span>
                </div>
                <div id="employment-service-analysis-id" class="chart-type1"></div>
              </div>
            </div>
            <!-- 推荐次数与就业情况分析 -->
            <div class="two-chart-right">
              <div class="chart-container" v-show="isShowChart">
                <div class="four-chart-mini-title">
                  <span>推荐次数与就业情况分析</span>
                  <span class="title-bk-container"></span>
                </div>
                <div id="recommended-frequency-analysis-id" class="chart-type1"></div>
              </div>
            </div>
          </div>
          <!-- 就业月份分布 -->
          <div class="middle-chart" style="width: 100%; height: 450px; border-bottom: 1px solid #1d2027">
            <div class="chart-container" v-show="isShowChart">
              <div class="four-chart-mini-title">
                <span>就业月份分布</span>
                <span class="title-bk-container"></span>
              </div>
              <div id="employment-month-distribution-id" class="chart-type1" style="height: 98.5%"></div>
            </div>
          </div>
          <!-- 数据来源分布 就业去向分布 -->
          <div class="middle-chart" style="width: 100%; height: 450px; border-bottom: 1px solid #1d2027">
            <div class="two-chart-left">
              <div class="chart-container" v-show="isShowChart">
                <div class="four-chart-mini-title">
                  <span>数据来源分布</span>
                  <span class="title-bk-container"></span>
                </div>
                <div id="data-sources-whereabouts-id" class="chart-type1" style="height: 98.5%"></div>
              </div>
            </div>
            <div class="two-chart-right">
              <div class="chart-container" v-show="isShowChart">
                <div class="four-chart-mini-title">
                  <span>就业去向分布</span>
                  <span class="title-bk-container"></span>
                </div>
                <div id="distribution-employment-whereabouts-id" class="chart-type1" style="height: 98.5%"></div>
              </div>
            </div>
          </div>
          <!-- 学历分布 专业分布 -->
          <div class="top-two-chart" style="width: 100%; height: 340px; border-bottom: 1px solid #1d2027">
            <!-- 学历分布 -->
            <div class="two-chart-left">
              <div class="chart-container" v-show="isShowChart">
                <div class="four-chart-mini-title">
                  <span>学历分布</span>
                  <span class="title-bk-container"></span>
                </div>
                <div id="education-distribution-id" class="chart-type1"></div>
              </div>
            </div>
            <!-- 专业分布 -->
            <div class="two-chart-right">
              <div class="chart-container" v-show="isShowChart">
                <div class="four-chart-mini-title">
                  <span>专业分布</span>
                  <span class="title-bk-container"></span>
                </div>
                <div id="professional-distribution-id" style="padding-left: 40px; top: 6px" class="chart-type1"></div>
              </div>
            </div>
          </div>
          <!-- 毕业高校就业人数TOP10  就业单位就业人数TOP10 -->
          <div class="bottom-two-chart" style="width: 100%; height: 340px;">
            <!-- 毕业高校就业人数TOP10 -->
            <div class="two-chart-left">
              <div class="chart-container" v-show="isShowChart">
                <div class="four-chart-mini-title">
                  <span>毕业高校就业人数TOP10</span>
                  <span class="title-bk-container"></span>
                </div>
                <div id="graduate-school-top10-id" class="chart-type1"></div>
              </div>
            </div>
            <!-- 就业单位就业人数TOP10 -->
            <div class="two-chart-right">
              <div class="four-chart-mini-title">
                <span>就业单位就业人数TOP10</span>
                <span class="title-bk-container"></span>
              </div>
              <div id="employment-units-top10-id" class="chart-type1"></div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 弹窗提示信息 -->
    <div class="second-search-box" v-show="isShowHelpMessageBox">
      <div class="graduates-help-wrapper">
        <div class="graduate-help-center-wrapper">
          <div class="top-bar-wrapper">离校未就业实名登记及就业服务流程<img src="../../assets/img/close-img.jpg"
                                                            style="position: absolute;right: 10px;top: 8px;cursor: pointer"
                                                            @click="showHelpMessageBox"></div>
          <img src="../../assets/img/graduates-help.png" width="600" style="margin-top: 20px;"/>
        </div>
      </div>
    </div>

  </div>
</template>
<script>
  import '../../assets/css/chartDetail.css'
  import {loadingOpt} from '../../assets/js/utils.js'
  import {getGraduateJobAnalyze} from '../../api/api'

  export default {
    props: ['isChange', 'fullScreen', 'isCollapse', 'pageChange'],
    data () {
      return {
        areaTitle: '',
        height: 800,
        canShow: true,
        showFloating: false,
        leftAnimate: '',
        navWidth: '800',
        top: '70',
        isShowChart: true,

        year: 2018,
        allTotal: '0',
        job_total: '0',
        rate: '0',
        isShowHelpMessageBox: false,
      }
    },
    mounted () {
      setTimeout(() => {
        this.getContentH();
        this.initMyChart();
        this.getData();
      }, 1);
    },
    watch: {
      isChange () {
        setTimeout(() => {
          this.getContentH();
          setTimeout(() => {
            this.resizeMyChart();
          }, 1)
        }, 211)
      },
      isCollapse (val) {
        this.getContentH();
      },
      isShowHelpMessageBox (val) {
        let zIndex = val ? 200 : 10000002;
        document.querySelector('.el-header').style.zIndex = zIndex;
      },
    },
    methods: {
      getData () {
        this.loadingMyChart(true);
        // 发送请求

        getGraduateJobAnalyze('hr/graduateJobAnalyze')
          .then((response) => {
            if (response.code == 0) {
              this.isShowChart = true;
              this.loadingMyChart(false);

              let data = response.data;

              this.allTotal = data.totals;
              this.job_total = data.job_total;
              this.rate = Number((data.rate * 100).toFixed(2));


              this.drawEmploymentServiceAnalysis(data.servers);
              this.drawRecommendedFrequencyAnalysis(data.cis);
              this.drawEmploymentMonthDistribution(data.oris);
              this.drawDataSourcesWhereabouts(data.sources);
              this.drawDistributionEmploymentWhereabouts(data.wheres);

              this.drawEducationDistribution(data.edus);
              this.drawProfessionalDistribution(data.pros);
              this.drawGraduateSchoolTop10(data.colleges);
              this.drawEmploymentUnitsTop10(data.units);

            } else {
              this.isShowChart = false;
            }
          });

      },
      // 就业服务与就业情况分析
      drawEmploymentServiceAnalysis (json) {
        let xData = [];
        let number = [];
        let numberRate = [];

        json.map((item) => {
          if (item.title) {
            xData.push(item.title);
            number.push(item.count);
            let rate = Number((item.rate * 100).toFixed(2));
            numberRate.push(rate);
          }
        });

        let xAxisData = [];
        xData.forEach((item, idx) => {
          if (item) {
            let temp = item && this.filterLogText(item);
            xAxisData.push(temp)
          }
        });

        // 为了保留单位
        xAxisData.reverse();
        xData.reverse();
        number.reverse();
        numberRate.reverse();

        let option = {
          grid: {
            top: 40,
            left: 120,
            right: 40,
            bottom: 40,
          },
          tooltip: {
            show: true,
            trigger: 'axis',
            axisPointer: {
              type: 'shadow'
            },
            textStyle: {
              fontSize: 12
            },
            formatter: function (params) {
              let i = params[0].dataIndex;
              let text = `<p>${xData[i]}</p>
                          <p>帮助就业人数: ${number[i]}人</p>
                          <p>就业率: ${numberRate[i]}%</p>`;
              return text;
            },
          },
          xAxis: {
            show: false,
          },
          yAxis: {
            name: '单位 : 人',
            // inverse: true,
            nameTextStyle: {
              color: '#fff',
            },
            data: xAxisData,
            axisLine: {
              show: true,
              color: '#fff',
            },
            axisTick: {
              show: true,
              color: '#fff',
            },
            axisLabel: {
              show: true,
              interval: 0,
              textStyle: {
                color: '#fff',
                lineHeight: 18,
              },
            }
          },
          series: [{
            type: 'bar',
            data: number,
            stack: 'age',
            color: '#3281fd',
            barWidth: '40%',
            barMaxWidth: 30,
            label: {
              show: true,
              position: 'right',
              color: '#fff',
              formatter: function (param) {
                return param.data;
              }
            }
          }]
        };
        this.employmentServiceAnalysis.setOption(option);
      },
      // 推荐次数与就业情况分析
      drawRecommendedFrequencyAnalysis (json) {

        let axisLineData = [];
        let number = [];
        let numberRate = [];
        let hiddenData = [];

        json.forEach((item, index) => {
          if (item.title) {
            axisLineData.push(item.title);
            number.push(Number(item.count));
            let rate = Number((item.rate * 100).toFixed(2));
            numberRate.push(rate);
          }
        });

        let tempSum = 0;
        let tempValue = 0;
        number.map((item, index) => {
          if (index == 0) {
            tempValue = tempSum = 0;
          } else {
            tempSum += item;
            tempValue = number[0] - tempSum;
          }

          hiddenData.push(tempValue);
        });

        let option = {
          grid: {
            top: 40,
            left: 60,
            right: 80,
            bottom: 60,
          },
          tooltip: {
            show: true,
            trigger: 'axis',
            axisPointer: {
              type: 'shadow'
            },
            textStyle: {
              fontSize: 12
            },
            formatter: function (params) {
              let i = params[0].dataIndex;
              let text = `<p>推荐次数: ${axisLineData[i]}</p>
                          <p>帮助就业人数: ${number[i]}人</p>
                          <p>就业率: ${numberRate[i]}%</p>`;
              return text;
            },
          },
          xAxis: {
            name: '推荐次数',
            nameTextStyle: {
              color: '#fff',
            },
            type: 'category',
            data: axisLineData,
            axisLine: { //x轴的横线是否显示
              show: true,
              lineStyle: {
                color: '#2a4565'
              }
            },
            axisTick: { //x轴的刻度短竖线是否显示
              show: false
            },
            axisLabel: {
              show: true,// 显示x轴坐标数值
              interval: 0,
              textStyle: {
                color: '#fff',
                lineHeight: 18,
              },
              formatter: function (val) {
                let length = val.length;
                let txt1 = val.slice(0, 2);
                let txt2 = val.slice(2, length);
                return `{a|${txt1}}\n${txt2}`
              },
              rich: {
                a: {
                  lineHeight: 16
                }
              }
            },
          },
          yAxis: {
            name: '单位：人',
            nameTextStyle: {
              color: '#fff',
            },
            position: 'left',
            axisLine: {
              show: true,
              lineStyle: {
                color: '#2a4565'
              }
            },
            splitLine: {
              show:true,
              lineStyle:{
                type:'dashed',
                color:'#2a4565'
              }
            },
            axisTick: {
              show: false
            },
            axisLabel: {
              show: true,
              color: '#fff'
            },
          },
          series: [
            {
              type: 'bar',
              stack: '推荐次数与就业情况分析',
              color: 'rgba(0,0,0,0)',
              data: hiddenData
            },
            {
              type: 'bar',
              stack: '推荐次数与就业情况分析',
              color: '#3281fd',
              label: {
                normal: {
                  show: true,
                  position: 'top',
                  color: '#fff',
                }
              },
              barWidth: '50%',
              barMaxWidth: 30,
              barMinWidth: 30,
              data: number
            }
          ]
        };
        this.recommendedFrequencyAnalysis.setOption(option);
      },
      // 就业月份分布
      drawEmploymentMonthDistribution (json) {
        let legend = ['就业登记人数'];
        let XAxis = [];
        let allNumber = [];

        json.map((item) => {
          if (item.title) {
            XAxis.push(item.title);
            allNumber.push(item.num);
          }
        });


        let showFormatter = function (params) {
          return `<sapn style="color: #fff">${legend[0]}</sapn></br>
                          <span style="color: #fff">月份: ${XAxis[params[0].dataIndex]}</span></br>
                          <span style="color: #fff">人数: ${allNumber[params[0].dataIndex]}人</span>`
        };
        let option = {
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'line',
              label: {
                backgroundColor: '#6a7985'
              }
            },
            show: true,
            textStyle: {
              fontSize: 12
            },
            formatter: showFormatter,
          },
          legend: {
            data: legend,
            textStyle: {
              color: '#fff',
            }
          },
          grid: {
            top: '40',
            left: '80',
            right: '40',
            bottom: '80',
          },
          xAxis: [
            {
              name: '',
              nameTextStyle: {
                color: '#fff',
              },
              type: 'category',
              boundaryGap: false,
              data: XAxis,
              axisTick: {
                show: false
              },
              axisLine: {
                show: true,
                lineStyle: {
                  color: '#2a4565'
                }
              },
              axisLabel: {
                formatter: '{value}',
                textStyle: {
                  color: '#fff'
                }
              },
            }
          ],
          yAxis: [
            {
              splitNumber: 7,
              axisPointer: {
                label: {
                  precision: 0
                }
              },
              name: '单位 : 人',
              nameTextStyle: {
                color: '#fff',
              },
              type: 'value',
              axisLine: {
                show: true,
                lineStyle: {
                  color: '#2a4565'
                }
              },
              axisLabel: {
                formatter: '{value}',
                textStyle: {
                  color: '#fff'
                }
              },
              splitLine: {
                show: false
              }
            }
          ],
          series: [
            {
              name: legend[0],
              type: 'line',
              color: 'rgba(41, 176, 158, 0.4)',
              smooth: true,
              symbol: 'none',
              itemStyle: {
                normal: {
                  areaStyle: {
                    type: 'default'
                  },
                },
              },
              data: allNumber,
            }
          ]
        };
        this.employmentMonthDistribution.setOption(option);
      },
      // 数据来源分布
      drawDataSourcesWhereabouts (json) {
        let legendData = [];
        let pieObjArray = [];

        json.map((item) => {
          if (item.title) {
            let tempObj = {};
            let tempLegenObj = {};

            tempObj.value = item.num;
            tempObj.numberRatio = (Number(item.rate) * 100).toFixed(2);
            tempObj.title = item.title;
            let tempTitle = '';
            if (item.title.length > 10) {
              tempTitle = item.title.substring(0, 10) + '\n' + item.title.substring(10, item.title.length);
              tempLegenObj.textStyle = {padding: [24, 0, 0, 0]};
            } else {
              tempTitle = item.title;
            }

            tempObj.name = tempTitle + '\n' + tempObj.numberRatio + '%';
            tempObj.number = item.num;

            tempLegenObj.name = tempObj.name;

            pieObjArray.push(tempObj);
            legendData.push(tempLegenObj);
          }
        });

        let option = {
          tooltip: {
            confine: true,
            trigger: 'item',
            formatter: function (params) {
              return `<span style="color: #fff; font-size: 12px">就业登记人数</span></br>
                      <span style="color: #fff; font-size: 12px">数据来源: ${params.data.title}</span></br>
                      <span style="color: #fff; font-size: 12px">人数: ${params.data.number} 人</span></br>
                      <span style="color: #fff; font-size: 12px">占比: ${params.data.numberRatio}%</span>`;
            }
          },
          legend: {
            orient: 'vertical',
            x: '70%',
            y: '20%',
            icon: 'rect',
            itemWidth: 10,
            itemHeight: 10,
            itemGap: 20,
            selectedMode: false,
            textStyle: {
              color: '#fff',
              padding: [14, 0, 0, 0]
            },
            data: legendData,
          },
          series: [
            {
              minAngle: 5,
              type: 'pie',
              radius: ['40%', '60%'],
              center: ['40%', '40%'],
              avoidLabelOverlap: false,
              hoverAnimation: false,
              animation: false,
              label: {
                show: false,
              },
              labelLine: {
                normal: {
                  show: false
                }
              },
              itemStyle: {
                color: function (params) {
                  let colorList = ['#3281FD', '#FF6A93', '#FFD66A'];
                  return colorList[params.dataIndex]
                }
              },
              data: pieObjArray
            }
          ]
        };

        this.dataSourcesWhereabouts.setOption(option);
      },
      // 就业去向分布
      drawDistributionEmploymentWhereabouts (json) {
        let xAxisData = [];
        let originalXData = [];
        let number = [];
        let numberRatio = [];

        json.map((item) => {
          if (item && item.title) {

            let tempTitle = '';

            if (item.title.length > 8) {
              tempTitle = item.title.substring(0, 4) + '\n' + item.title.substring(4, item.title.length);
            }
            else if (item.title.length > 4) {
              tempTitle = item.title.substring(0, 2) + '\n' + item.title.substring(2, item.title.length);
            } else {
              tempTitle = item.title;
            }


            originalXData.push(item.title);
            xAxisData.push(tempTitle);
            number.push(item.count);
            let rate = Number((item.rate * 100).toFixed(2));
            numberRatio.push(rate);
          }
        });

        let that = this;
        let option = {
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'none'
            },
            textStyle: {
              fontSize: 12
            },
            formatter: function (params) {
              let index = params[0].dataIndex;
              let txt = `<p>就业登记人数</p>
                         <p>就业去向：${originalXData[index]}</p>
                         <p>人数：${number[index]}人</p>
                         <p>占比：${numberRatio[index]}%</p>`;
              return txt;
            },
          },
          grid: {
            top: '40',
            left: '80',
            right: '40',
            bottom: '80',
          },
          xAxis: {
            data: xAxisData,
            axisTick: {show: false},
            axisLine: {show: false},
            axisLabel: {
              interval: 0,
              textStyle: {
                color: '#fff'
              }
            }
          },
          yAxis: {
            splitLine: {show: false},
            axisTick: {show: false},
            axisLine: {show: false},
            axisLabel: {show: false}
          },
          color: ['#32cfe8'],
          series: [{
            barMinHeight: 5,
            name: 'hill',
            type: 'pictorialBar',
            barCategoryGap: '-100%',
            symbol: 'path://M0,10 L10,10 C5.5,10 5.5,5 5,0 C4.5,5 4.5,10 0,10 z',
            itemStyle: {
              normal: {
                opacity: 0.6
              },
              emphasis: {
                opacity: 1
              }
            },
            label: {
              show: true,
              position: 'top',
              formatter: function (params) {
                let index = params.dataIndex;
                return `${number[index]}`
              },
              color: '#fff'
            },
            data: number,
          }]
        };
        this.distributionEmploymentWhereabouts.setOption(option);
      },
      // 学历分布
      drawEducationDistribution (json) {
        let xAxisData = [];
        let number = [];
        let ratio = [];

        json.map((item) => {
          if (item.title) {
            xAxisData.push(item.title);
            number.push(item.count);
            let tempRatio = Number((item.rate * 100).toFixed(2));
            ratio.push(tempRatio)
          }
        });


        let option = {
          grid: {
            top: 20,
            left: 10,
            right: 10,
            bottom: 80,
          },
          tooltip: {
            show: true,
            trigger: 'axis',
            axisPointer: {
              type: 'shadow'
            },
            textStyle: {
              fontSize: 12
            },
            formatter: function (params) {
              let i = params[0].dataIndex;
              let text = `<p>就业登记人数</p>
                          <p>学历: ${params[0].name}</p>
                          <p>人数: ${number[i]}人</p>
                          <p>就业率: ${params[0].data}%</p>`;
              return text;
            }
          },
          yAxis: {
            show: false,
          },
          xAxis: {
            data: xAxisData,
            axisLine: {
              show: false, // 显示x轴坐标线并设置为虚线
            },
            axisTick: {
              show: false // 不显示x轴坐标的刻度
            },
            axisLabel: {
              show: true,// 显示x轴坐标数值
              interval: 0,
              textStyle: {
                color: '#fff',
                lineHeight: 18,
              },
            }
          },
          series: [{
            type: 'bar',
            data: ratio,
            stack: 'age',
            color: '#ff6a93',
            barWidth: '40%',
            barMaxWidth: 30,
            label: {
              show: true,
              position: 'top',
              color: '#fff',
              formatter: function (param) {
                return param.data + '%';
              }
            }
          }]
        };
        this.educationDistribution.setOption(option);
      },
      // 专业分布
      drawProfessionalDistribution (json) {
        let mapDataArr = [];
        json.forEach((item, index) => {
          let tempObj = {};

          tempObj.name = item.title;
          tempObj.value = item.count;
          tempObj.rate = item.rate;

          // 二级
          let tempChildrenArr = [];
          if (item.childs && item.childs.length) {
            item.childs.forEach((itemChilds, index) => {
              let tempChildrenObj = {};
              tempChildrenObj.name = itemChilds.title;
              tempChildrenObj.value = itemChilds.num;
              tempChildrenObj.rate = itemChilds.rate;
              tempChildrenArr.push(tempChildrenObj);
            });
          }
          if (tempChildrenArr.length) {
            tempObj.children = tempChildrenArr;
          }
          mapDataArr.push(tempObj);
        });

        let option = {
          tooltip: {
            trigger: 'item',
            textStyle: {
              fontSize: 12,
            },
            formatter: function (params) {
              let rate = Number((params.data.rate * 100).toFixed(2));
              let text = `<p>就业登记人数</p>
                      <p>专业:${params.name}</p>
                      <p>人数:${params.value}人</p>`;

              if (rate && rate != 'NaN') {
                text += `<p>就业率:${rate}%</p>`
              }

              return text;
            }
          },
          series: [
            {
              bottom: '20%',
              name: '全部专业',
              type: 'treemap',
              leafDepth: 1,
              levels: [
                {
                  colorSaturation: [0.6, 0.3],
                  itemStyle: {
                    normal: {
                      color: '#55cdb7',

                    }
                  }
                },
                {
                  colorSaturation: [0.6, 0.3],
                  itemStyle: {
                    normal: {
                      color: '#55cdb7',

                    }
                  }
                }
              ],
              breadcrumb: {
                show: true,
                top: '81%',
                itemStyle: {
                  color: '#55cdb7',
                  borderColor: '#fff',
                  shadowColor: "#fff"
                }
              },
              data: mapDataArr
            }
          ]
        };

        this.professionalDistribution.setOption(option);
      },
      // 毕业高校就业人数TOP10
      drawGraduateSchoolTop10 (json) {
        let xData = [];
        let number = [];

        json.map((item) => {
          if (item.title) {
            xData.push(item.title);
            number.push(item.num);
          }
        });

        let xAxisData = [];
        xData.forEach((item, idx) => {
          if (item) {
            let temp = item && this.filterLogText(item);
            xAxisData.push(temp)
          }
        });

        // 为了保留单位
        xAxisData.reverse();
        xData.reverse();
        number.reverse();

        let option = {
          grid: {
            top: 40,
            left: 120,
            right: 40,
            bottom: 60,
          },
          tooltip: {
            show: true,
            trigger: 'axis',
            axisPointer: {
              type: 'shadow'
            },
            textStyle: {
              fontSize: 12
            },
            formatter: function (params) {
              let i = params[0].dataIndex;
              let text = `<p>${xData[i]}</p>
                          <p>就业人数: ${number[i]}人</p>`;
              return text;
            },
          },
          xAxis: {
            show: false,
          },
          yAxis: {
            name: '单位 : 人',
            // inverse: true,
            nameTextStyle: {
              color: '#fff',
            },
            data: xAxisData,
            axisLine: {
              show: true,
              color: '#fff',
            },
            axisTick: {
              show: true,
              color: '#fff',
            },
            axisLabel: {
              show: true,
              interval: 0,
              textStyle: {
                color: '#fff',
                lineHeight: 18,
              },
            }
          },
          series: [{
            type: 'bar',
            data: number,
            stack: 'age',
            color: '#3281fd',
            barWidth: '40%',
            barMaxWidth: 30,
            label: {
              show: true,
              position: 'right',
              color: '#fff',
              formatter: function (param) {
                return param.data;
              }
            }
          }]
        };
        this.graduateSchoolTop10.setOption(option);
      },
      // 就业单位就业人数TOP10
      drawEmploymentUnitsTop10 (json) {
        let xData = [];
        let number = [];

        json.map((item) => {
          if (item.title) {
            xData.push(item.title);
            number.push(item.num);
          }
        });

        let xAxisData = [];
        xData.forEach((item, idx) => {
          if (item) {
            let temp = item && this.filterLogText(item);
            xAxisData.push(temp)
          }
        });

        // 为了保留单位
        xAxisData.reverse();
        xData.reverse();
        number.reverse();

        let option = {
          grid: {
            top: 40,
            left: 120,
            right: 40,
            bottom: 60,
          },
          tooltip: {
            show: true,
            trigger: 'axis',
            axisPointer: {
              type: 'shadow'
            },
            textStyle: {
              fontSize: 12
            },
            formatter: function (params) {
              let i = params[0].dataIndex;
              let text = `<p>${xData[i]}</p>
                          <p>就业人数: ${number[i]}人</p>`;
              return text;
            },
          },
          xAxis: {
            show: false,
          },
          yAxis: {
            name: '单位 : 人',
            // inverse: true,
            nameTextStyle: {
              color: '#fff',
            },
            data: xAxisData,
            axisLine: {
              show: true,
              color: '#fff',
            },
            axisTick: {
              show: true,
              color: '#fff',
            },
            axisLabel: {
              show: true,
              interval: 0,
              textStyle: {
                color: '#fff',
                lineHeight: 18,
              },
            }
          },
          series: [{
            type: 'bar',
            data: number,
            stack: 'age',
            color: '#55cdb7',
            barWidth: '40%',
            barMaxWidth: 30,
            label: {
              show: true,
              position: 'right',
              color: '#fff',
              formatter: function (param) {
                return param.data;
              }
            }
          }]
        };
        this.employmentUnitsTop10.setOption(option);
      },
      initMyChart () {
        this.employmentServiceAnalysis = this.$echarts.init(document.getElementById('employment-service-analysis-id'));
        this.recommendedFrequencyAnalysis = this.$echarts.init(document.getElementById('recommended-frequency-analysis-id'));
        this.employmentMonthDistribution = this.$echarts.init(document.getElementById('employment-month-distribution-id'));
        this.dataSourcesWhereabouts = this.$echarts.init(document.getElementById('data-sources-whereabouts-id'));
        this.distributionEmploymentWhereabouts = this.$echarts.init(document.getElementById('distribution-employment-whereabouts-id'));
        this.educationDistribution = this.$echarts.init(document.getElementById('education-distribution-id'));
        this.professionalDistribution = this.$echarts.init(document.getElementById('professional-distribution-id'));
        this.graduateSchoolTop10 = this.$echarts.init(document.getElementById('graduate-school-top10-id'));
        this.employmentUnitsTop10 = this.$echarts.init(document.getElementById('employment-units-top10-id'));
      },
      resizeMyChart () {
        this.employmentServiceAnalysis.resize();
        this.recommendedFrequencyAnalysis.resize();
        this.employmentMonthDistribution.resize();
        this.dataSourcesWhereabouts.resize();
        this.distributionEmploymentWhereabouts.resize();
        this.educationDistribution.resize();
        this.professionalDistribution.resize();
        this.graduateSchoolTop10.resize();
        this.employmentUnitsTop10.resize();
      },
      clearMyChart () {
        this.employmentServiceAnalysis.clear();
        this.recommendedFrequencyAnalysis.clear();
        this.employmentMonthDistribution.clear();
        this.dataSourcesWhereabouts.clear();
        this.distributionEmploymentWhereabouts.clear();
        this.educationDistribution.clear();
        this.professionalDistribution.clear();
        this.graduateSchoolTop10.clear();
        this.employmentUnitsTop10.clear();
      },
      loadingMyChart (val) {
        if (val) {
          this.employmentServiceAnalysis.showLoading(loadingOpt);
          this.recommendedFrequencyAnalysis.showLoading(loadingOpt);
          this.employmentMonthDistribution.showLoading(loadingOpt);
          this.dataSourcesWhereabouts.showLoading(loadingOpt);
          this.distributionEmploymentWhereabouts.showLoading(loadingOpt);
          this.educationDistribution.showLoading(loadingOpt);
          this.professionalDistribution.showLoading(loadingOpt);
          this.graduateSchoolTop10.showLoading(loadingOpt);
          this.employmentUnitsTop10.showLoading(loadingOpt);
        } else {
          this.employmentServiceAnalysis.hideLoading();
          this.recommendedFrequencyAnalysis.hideLoading();
          this.employmentMonthDistribution.hideLoading();
          this.dataSourcesWhereabouts.hideLoading();
          this.distributionEmploymentWhereabouts.hideLoading();
          this.educationDistribution.hideLoading();
          this.professionalDistribution.hideLoading();
          this.graduateSchoolTop10.hideLoading();
          this.employmentUnitsTop10.hideLoading();
        }
      },
      // 设置高度
      getContentH () {
        let height = document.querySelector('body').clientHeight;
        let bodyWidth = document.querySelector('body').clientWidth;

        let top = 0;
        let barHeight = 0;
        let titleHeight = 44;
        let marginHeight = 40;


        let sideWidth = 0;

        // 全屏的时候没有
        if (document.querySelector('.el-header')) {
          top = 70;
          barHeight = document.querySelector('.el-header').clientHeight;
        }

        // 左边的全屏也没有
        if (document.querySelector('.el-aside')) {
          sideWidth = document.querySelector('.el-aside').clientWidth;
          this.leftAnimate = 'open-left-menu'
        } else {
          this.leftAnimate = 'close-left-menu'
        }

        this.top = top;
        this.navWidth = bodyWidth - sideWidth;
        this.height = height - barHeight - titleHeight - marginHeight - 6;
      },
      // 字数太长省略
      filterLogText (value, leng = 7) {
        if (value.length <= leng) {
          return value;
        } else {
          return value.slice(0, leng) + '...';
        }
      },
      mouseenter () {
        this.showFloating = true;
      },
      mouseleave () {
        this.showFloating = false;
      },
      showHelpMessageBox () {
        this.isShowHelpMessageBox = !this.isShowHelpMessageBox;
      }
    },
  }
</script>

<style scoped>

  /* css 引用 */
  @import '../../assets/css/decision.css';
  /* 必须在decision 下*/
  @import '../../assets/css/portrait-personk-detail.css';

  .min-card-subTitle {
    font-size: 14px;
    position: relative;
    top: -10px;

    display: block;
    color: #fff;
    margin-bottom: 3px;
  }

  .two-chart-left,
  .two-chart-right {
    width: 50%;
    height: 100%;
    float: left;
    box-sizing: border-box;
    overflow: hidden;
  }

  .graduate-help-center-wrapper {
    width: 650px;
    height: 650px;
    background: #1C2340;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
  }

  .graduates-help-wrapper {
    width: 100%;
    height: 100%;
    color: #ffffff;
    background: rgba(40, 60, 85, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .top-bar-wrapper {
    width: 650px;
    height: 30px;
    line-height: 30px;
    background: #2E3457;
    padding-left: 20px;
    box-sizing: border-box;
  }

  .chart-next {
    float: right;
    cursor: pointer;
    text-decoration: none;
  }

  .next-btn {
    cursor: pointer;
    float: right;
    margin-top: 8px;
    margin-right: 9px;
    line-height: 28px;
    height: 28px;
    padding: 0 15px;
    border-radius: 5px;
    border: solid 1px #67ffdb;
    color: #67ffdb;
  }

  .help-message {
    width: 100%;
    height: 30px;
    position: relative;
  }

  .help-message-wrapper {
    color: #fff;
    float: right;
    font-size: 12px;
    width: 150px;
    height: 30px;
    cursor: pointer;

    display: flex;
    justify-content: center;
    align-items: Center;

    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }

  .help-message-wrapper:hover {
    color: #1297f7;
  }


</style>
